String-Interpolated Subroutine Calls

Eric Wilhelm on 2005-12-10T19:49:35

From "perldoc constant":

Constants defined using this module cannot be interpolated into strings like variables.

But:

use constant foo => 7; print "foo: @{[foo]}\n";

Whee!


I found this...

sigzero on 2005-12-10T22:12:49

This was in "Programming Perl":

Since these constants don't have a $ on the front, you can't interpolate them directly into double-quotish strings, although you may do so indirectly :

print "The value of PI is @{[ PI ]}.\n";

I use 5.8.7 and that statement isn't in my perldoc for constant.